/* JS
 * scripts_new.js
 */


jQuery(document).ready(function(){
    flg_apm.baseVals={};
    flg_apm.baseVals.win=$(window);
    flg_apm.baseVals.winHw=flg_apm.baseVals.win.height();
    flg_apm.baseVals.winw=flg_apm.baseVals.win.width();
    flg_apm.appHome.initClicks();
    flg_apm.appTopBar.init();
    flg_apm.initMainRollover();
    f=$('#do_sending_test');
//$(f).val('');
});

if(flg_apm==undefined){
    flg_apm={};
}

flg_apm.config={
    dateFormat:'mm/dd/yyyy',
    lang:'en'
}
flg_apm.initMainRollover=function(){

    $('.hasTooltip').off('mouseover').on('mouseover',function(){
        $(this).tooltip();
        $(this).tooltip('show');
    });
    $('.hasPopover').off('mouseover').on('mouseover',function(){
        arg={
            placement:'right'
        }
        $(this).popover(arg);
        $(this).popover('show')
    });
    $('.hasPopover').off('mouseout').on('mouseout',function(){
        $(this).popover('hide')
    });
}
flg_apm.appHome=function(){
    }
flg_apm.appTopBar=function(){
    }

flg_apm.appHome.saveNeverSeeAnymore=function(id){
    $.ajax({
        url: ajaxurl ,
        type: "POST",
        data: "action=apm_ajax_savesettings&do_ajax=save_never_see_anymore&id="+id,
        error: function(data){
            alert('An error occured,  please try again');
        },
        success: function(data){
        }
    });
}
flg_apm.appHome.initClicks=function(){
    $('#apm_moduleslist span.btn a').off('mouseover').on('mouseover',function(){
        i=$(this).find('i');
        $(i).addClass('icon-white');
        p=$(this).parents('span.btn');
        $(p).addClass('btn-info');
    });
    $('#apm_moduleslist span.btn a').off('mouseout').on('mouseout',function(){
        i=$(this).find('i');
        $(i).removeClass('icon-white');
        p=$(this).parents('span.btn');
        $(p).removeClass('btn-info');
    });
    $('.do_submit_settings').off('click').on('click',function(){
        p=$(this).parents('.settingform');
        $(p).submit();
    });
    $('.topintrotext_close').off('click').on('click',function(){
        p=$(this).parents('.well');
        $(p).fadeOut(500);
    });
    $('.topintrotext_closealways').off('click').on('click',function(){
        p=$(this).parents('.well');
        flg_apm.appHome.saveNeverSeeAnymore($(p).attr('id'));
        $(p).fadeOut(500);
    });
    $('.apm_topnav_openmodgrid').off('click').on('click',function(){
        p=$(this).parent();
        mod=$(p).attr('data-module');
        app=$(p).attr('data-app');
        document.location.href='admin.php?page='+app+'-'+mod;

    });
    $('.apm_topnav_addmodrec').off('click').on('click',function(){
        p=$(this).parent();
        mod=$(p).attr('data-module');
        document.location.href='post-new.php?post_type='+mod;

    });
}

flg_apm.appTopBar.init=function(){
    if( flg_apm.baseVals.winw<=1042){
        o=$('.hideIfWidthMax');
        $(o).hide();
    }

//  class=""
}

